package lcr;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Test0080 {
    public static void main(String[] args) {
        new Solution0080_1().combine(4,2);
    }
}

class Solution0080_1 {

    List<List<Integer>> ans=new ArrayList<>();

    public List<List<Integer>> combine(int n, int k) {
        List<Integer> records = new ArrayList<>(k);

        traceback(1,n,k,records);

        return ans;
    }

    public void traceback(int start,int n,int k,List<Integer> records){
        if (k==0){
            ans.add(new ArrayList<>(records));
            return;
        }

        for (int i = start; i <= n-k+1; i++) {
            records.add(i);

            traceback(i+1,n,k-1,records);

            records.remove(records.size()-1);
        }
    }
}
